package com.wondertek.mam.tag.config;

import com.google.common.base.Charsets;
import com.wondertek.mam.tag.wordSource.impl.BaiduHotTodayWordSource;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by wangdongxu on 2017-09-06 下午 13:49:22.
 */
public class Constant {
    private static final Logger LOGGER = LoggerFactory.getLogger(Constant.class);
    public static Integer TAG_SIZE = 20;
    public static Float HOT_WQ_RATE = 0.5f; //热度和词频的权重比例
    public static Float TITLE_RATE = 1f; //标题词汇的增倍率
    /**
     *1. 名词,n=名词,nr=人名,ns=地名,nt=团体机构名,nz=其它专名
     *2. 动词,v=动词,vd=副动词,vn=名动词,vi=不及物动词
     *3. 形容词,a=形容词,ad=副形容词,an=名形容词
     *4. 数词,m=数词,mh=中文数词,mb=百分数词,mf=分数词,mx=小数词,mq=数量词
     *5. 量词,a=量词
     *6. 代词,r=代词,rr=人称代词,rz=指示代词
     *7. 副词,d=副词
     *8. 介词,p=介词
     *9. 连词,c=连词
     *10. 助词,u=助词
     *11. 拟声词,o=拟声词
     *12. 叹词,e=叹词
     *13. 时间词,t=时间词,tq=时间量词,tdq=日期量词
     *14. 处所词,s=处所词
     *15. 方位词,f=方位词
     *16. 区别词,b=区别词
     *17. 语气词,y=语气词
     *18. 状态词,z=状态词
     *19. 词组,l=词组
     *20. 英文单词,w=英文单词
     */
    public static List<String> EXCLUDE_PART_OF_SPEECH = Arrays.asList("m","mh","mb","mf","mx","mq","a","r","rr","rz","d","p","c","u","o","e","b","y");
    public static String BAIDU_HOTWORD_URL_PREFIX = "http://top.baidu.com/buzz?b=";
    //public static String THESAURUS_FILE = "D:\\Java\\data\\studySp\\mam-tag\\src\\main\\resources\\thesaurus.txt";
    public static List<String> BAIDU_HOTWORD_IDS = new ArrayList<>();
    public static List<String> SINA_HOTWORD_URLAFTER = Arrays.asList("cate=realtimehot","cate=total&key=all","cate=total&key=films","cate=total&key=person");
    public static Integer BAIDU_HOT_THRESHOLD = 10000;
    static {
        InputStream fis = Constant.class.getClassLoader().getResourceAsStream("baidu-hotword-d.txt");
        try {
            BAIDU_HOTWORD_IDS = IOUtils.readLines(fis, Charsets.UTF_8).parallelStream().map(s -> s.split(":")[0]).collect(Collectors.toList());
        } catch (IOException e) {
            LOGGER.error("百度热点标号文件读取失败");
        }
    }
    public enum TAG_CLASS {
        MOVIES(1),                  //电影
        TVSHOWS(2),                 //电视剧
        DOCUMENTARY(3),             //纪实
        SPORTS(4),                  //体育
        NEWS(5),                    //新闻
        VARIETY(6),                 //综艺
        ENTERTAINMENT(7),           //娱乐
        CARTOONS(8),                //动漫
        TOURISM(9),                 //旅游
        ORIGINAL(10),               //原创
        EDUCATION(11),              //教育
        AUDIO(12),                  //音频
        MILITARY(13),               //军事
        HEALTH(14),                 //健康
        FUNNY(15),                  //搞笑
        LEGAL_SYSTEM(16),           //法制
        PERSONAL_RADIO_STATION(17), //个人电台
        RADIO(18),                  //广播剧
        QUYI(19),                   //曲艺
        AUDIO_NOVELS(20),           //有声小说
        FINANCE(21),                //财经
        FASHION(22),                //时尚
        MUSIC_VIDEOS(23),           //MV
        THE_OLYMPIC_GAMES(24),      //奥运
        ADVERTISING(25);            //广告
        private int v;
        TAG_CLASS(int v){
            this.v = v;
        }
        public int getValue(){
            return this.v;
        }
        public static boolean isClassId(int classId){
            return classId>=1&&classId<=25;
        }
    }
}
